/*+**************************************************************************/
/***                                                                      ***/
/***   This file is distributed under a BSD license.                      ***/
/***   See LICENSE.txt for details.                                       ***/
/***                                                                      ***/
/**************************************************************************+*/

/****************************************************************************/
/***                                                                      ***/
/***   (C) 2005 Dierk Ohlerich, all rights reserved                       ***/
/***                                                                      ***/
/****************************************************************************/

asc
{
  cbuffer JustMatrix : register(c0) : slot vs 0
  {
    row_major float4x4 mvp;     // rotation for light vector (not really needed)
  };
}

material TorusShader
{

  // the vertex sahder

  vs
  {
    asc vs_2_0                 // hlsl code
    {
      use JustMatrix;
      void main
      (
        in float3 in_pos : POSITION,            // input, from vertex array
        in float4 in_color : COLOR0,
        in float2 in_uv : TEXCOORD0,

        in float4 in_mat0 : TEXCOORD1,
        in float4 in_mat1 : TEXCOORD2,
        in float4 in_mat2 : TEXCOORD3,

        out float2 out_uv : TEXCOORD0,
        out float4 out_color : COLOR0,
        out float4 out_pos : POSITION,          // output, to pixel shader
      )
      {
        out_uv = in_uv;
        out_color = in_color;
        float4 temp;
        temp.x = dot(float4(in_pos,1),in_mat0);
        temp.y = dot(float4(in_pos,1),in_mat1);
        temp.z = dot(float4(in_pos,1),in_mat2);
        temp.w = 1;
        out_pos = mul(temp,mvp);
      }
    }
  }

  // the pixel shader. same as vertex shader...

  ps
  {
    asc ps_2_0
    {
      sampler2D s0 : register(s0);

      void main
      (
        in float2 uv : TEXCOORD0,
        in float4 col : COLOR0,
        out float4 result : COLOR0
      )
      {
        result = tex2D(s0,uv)*col;
      }
    }
  }
};
